package de.servicezombie.tcmdb;

import de.servicezombie.lang.ErrorCode;
import de.servicezombie.lang.ErrorCodeAware;

public class TcmdbException extends RuntimeException implements ErrorCodeAware {

	private static final long serialVersionUID = 1L;

	private ErrorCode errorCode = ErrorCode.UNSPECIFIED;

	public TcmdbException(String message, Throwable cause) {
		super(message, cause);
	}

	public TcmdbException(String message) {
		super(message);
	}

	public TcmdbException(Throwable cause) {
		super(cause);
	}
	
	public TcmdbException attachErrorCode(ErrorCode errorCode) {
		this.errorCode = errorCode;
		return this;
	}

	@Override
	public ErrorCode getErrorCode() {
		return errorCode;
	}
	
	protected void setErrorCode(ErrorCode errorCode) {
		this.errorCode = errorCode;
	}

	@Override
	public String toString() {
		return getClass().getSimpleName() + "[" + errorCode + "]: " + getMessage();
	}

	
}
